from django.shortcuts import render

# Create your views here.
import random
from rest_framework.response import Response
from rest_framework.generics import GenericAPIView
import logging

logger = logging.getLogger('django')


# url('^sms_codes/(?P<mobile>1[3-9]\d{9})/$', views.SMSCodeView.as_view()),
class SMSCodeView(GenericAPIView):
    """
    短信验证码
    传入参数：
        mobile,     image_code_id, text
    """

    def get(self, request, mobile):
        # 生成短信验证码
        sms_code = '%06d' % random.randint(0, 999999)
        print(sms_code)

        return Response({'message': 'OK'})
